package com.student.demo.controller;

import com.student.demo.entiy.LoginResult;
import com.student.demo.entiy.User;
import com.student.demo.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
public class UserController {

    @Autowired
    public LoginService userService;

    @PostMapping("/Login")
    public LoginResult verify(String userName, String password) {
        User user = new User();
        user.setUserName(userName);
        user.setPassword(password);

        return userService.verify(user);
    }

    @PostMapping("/Register")
    public void register(String userName, String phoneNumber, String password) {
        User user = new User();
        user.setUserName(userName);
        user.setPhoneNumber(phoneNumber);
        user.setPassword(password);

        userService.register(user);
    }
}
